import createHistory from 'history/CreateHashHistory'
import {actionFunc as mainTabActionFunc} from '@/components/MainTab/store'
import {store} from '@/store'
import {actionFunc as navLeftActionFunc} from '@/components/NavLeft/store'
import {fromJS} from 'immutable'

const history = createHistory()

history.listen((nextLocation)=>{
    store.dispatch(mainTabActionFunc.getLocation(nextLocation.pathname))
})
history.myPush = (params)=>{
    history.push(params.url)
    let menuKey = []
    menuKey.push(params.key)
    store.dispatch(navLeftActionFunc.updateSelectedMenu(fromJS(menuKey)))
}

export default history
